package com.zhai.domain.strategy.model.entity;

import cn.hutool.core.util.StrUtil;
import com.zhai.types.common.Constants;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

/**
 * @Description: 策略实体
 * @ClassName: StrategyEntity
 * @Author: zhaiyongxin
 * @Date: 2024/12/31 11:19
 * @Version: 1.0
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class StrategyEntity {

    /** 抽奖策略ID*/
    private Long strategyId;
    /** 抽奖策略描述*/
    private String strategyDesc;
    /** 规则模型，rule配置的模型同步到此表，便于使用*/
    private String ruleModels;

    //=========开始充血=======

    /**
     * 获取规则模型数组列表
     * @return
     */
    public String[] ruleModels(){
        if (StrUtil.isBlank(ruleModels)) {return null;}
        return ruleModels.split(Constants.SPLIT);
    }

    public String getRuleWeight(){
        String[] ruledModels = this.ruleModels();
        if (null == ruleModels) return null;
        for (String ruledModel : ruledModels) {
            if ("rule_weight".equals(ruledModel)) {
                return ruledModel;
            }
        }
        return null;
    }
}
